#include "mytextedit.h"

MyTextEdit::MyTextEdit(QWidget *parent) : QTextEdit(parent) {
    ctrl_flag = 0;
}

void MyTextEdit::rollIn()
{
    // 放大字体
    QFont font = this->font();
    int size = font.pointSize();
    size++;
    font.setPointSize(size);

    this->setFont(font);
}

void MyTextEdit::rollOut()
{
    // 缩小字体
    QFont font = this->font();
    int size = font.pointSize();
    size--;
    font.setPointSize(size);

    this->setFont(font);
}

// void MyTextEdit::wheelEvent(QWheelEvent *event)
// {
//     if (ctrl_flag) {
//         if (event->angleDelta().y() > 0) {
//             rollIn();
//         } else {
//             rollOut();
//         }
//     }
// }

// void MyTextEdit::keyPressEvent(QKeyEvent *event)
// {
//     ctrl_flag = (Qt::Key_Control == event->key());
// }
